home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Python 1.4 / Python 1.4 source / Demo / tkinter / matt / window-creation-w-location.py < prev   
Encoding:
Python Source  |  1996-08-26  |  874 b   |  39 lines  |  [TEXT/Pyth]

  1. from Tkinter import *
  2.  
  3. import sys
  4. sys.path.append("/users/mjc4y/projects/python/tkinter/utils")
  5. from TkinterUtils  import *
  6.  
  7. # this shows how to create a new window with a button in it that
  8. # can create new windows
  9.  
  10.  
  11. class Test(Frame):
  12.     def makeWindow(self, *args):
  13.     fred = Toplevel()
  14.  
  15.     fred.label = Canvas (fred, width="2i", height="2i")
  16.  
  17.     fred.label.create_line("0", "0", "2i", "2i")
  18.     fred.label.create_line("0", "2i", "2i", "0")
  19.     fred.label.pack()
  20.  
  21.     centerWindow(fred, self.master)
  22.  
  23.     def createWidgets(self):
  24.     self.QUIT = QuitButton(self)
  25.     self.QUIT.pack(side=LEFT, fill=BOTH)
  26.  
  27.     self.makeWindow = Button(self, text='Make a New Window',
  28.                  width=50, height=20,
  29.                  command=self.makeWindow)
  30.     self.makeWindow.pack(side=LEFT)
  31.  
  32.     def __init__(self, master=None):
  33.     Frame.__init__(self, master)
  34.     Pack.config(self)
  35.     self.createWidgets()
  36.  
  37. test = Test()
  38. test.mainloop()
  39.